<div class="filter-bar">
<form action="__CONTROLLER__/index" method="post" id="frm" >
	<div class="view">
		<div class="row clearfix">
			<div class="col-md-3 column ui-sortable">
			    <label class="col-sm-4 control-label">代理商名称</label>
			    <div class="col-sm-8">
				   <input type="text" class="form-control" name="agentName" value="{$params.agentName}" />
			    </div>
			</div>
			<div class="col-md-3 column ui-sortable">
			    <div class="col-sm-9">
			       <input type="hidden" name="status" value="{$params.stauts}" /> 
			       <input type="submit" class="btn btn-info submit" value="搜索"/>
			    </div>
			</div>
		</div>
	</div>
</form>
</div>
<hr/>
<table class="table table-hover">
 <thead>
  <tr>
   <th>ID</th>
   <th>订单编号</th>
   <th>代理商名称</th>
   <th>结算金额</th>
   <th>结算状态</th>
   <th>操作</th>
  </tr>
 </thead>
 <tbody>
  <volist name="settleList" id="vo">
   <tr>
    <td>{$vo.id}</td>
    <td>{$vo.order_no}</td>
    <td>{$vo.agent_name}</td>
    <td>{$vo.bonus}</td>
    <td>{$vo['status']?'已结算':'未结算'}</td>
    <td style="position: relative;">
    	<eq name="vo['status']" value="0"><input settle-id="{$vo['id']}" type="button" class="btn btn-info btnSettleAccounts" value="结算"/></eq>
    	<span id="submitMsg" class="label" style="position: absolute;top:0px;right:0px;"></span>
    </td>
   </tr>
  </volist>
 </tbody>
</table>
<div class="pagination">{$pagination}</div>

<script type="text/javascript">
$(function(){
    $(".btnSettleAccounts").click(function() {
    	var settleId = $(this).attr("settle-id");
    	var msg = $(this).parent().find("#submitMsg");
    	var btnSubmit = $(this);
    	if ( confirm("确认已将此笔订单结算打入对方银行卡？") ) {
            $.ajax({
            	type:"POST",
            	url:"__CONTROLLER__/settleAccountsPost",
            	async:true,
            	data: {"id": settleId},
            	beforeSend: function(){
            	    btnSubmit.data("value", btnSubmit.html()).html("<i class='fa fa-spin fa-spinner'></i> 正在提交中……").attr("disabled",true);
            	},
            	success: function(data){
            		msg.html(data.msg).removeClass().addClass(['label label-success','label label-danger'][data.error]).show().delay(3000).fadeOut('slow');
            		btnSubmit.remove();
            	},
            	error: function(error){
            		msg.html(error).removeClass().addClass("label label-danger");
            	},
            	complete: function(){
            	    btnSubmit.removeAttr("disabled").html(btnSubmit.data("value"));
            	}
            });
    	}
    });
});
</script>